<?php
namespace app\common\model;

use think\Model;

class InstallationLog extends Model
{
    
    protected $autoWriteTimestamp = true;
    
    public function admin()
    {
        return $this->hasOne('Admin','id','admin_id')->field('id,nick_name');
    }
    
    public function getOldValueAttr($value,$data)
    {

        if($data['type'] == 1){
            $value = InstallUser::where(['id'=>$value])->value('name');
        }elseif ($data['type'] == 2){
            $value = $value == 1 ? "新装":"更换";
        }
        return $value;
    }
    
    public function getValueAttr($value,$data)
    {
        
        if($data['type'] == 1){
            $value = InstallUser::where(['id'=>$value])->value('name');
        }elseif ($data['type'] == 2){
            $value = $value == 1 ? "新装":"更换";
        }
        return $value;
    }
}
